package test;

import java.sql.Date;
import java.text.SimpleDateFormat;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.validation.BindException;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;

/**
 * 员工管理
 * date：2012-9-1 21:31:00
 * 
 * @author Administrator
 *
 */
public class CommondEmpController extends AbstractCommandController {

	@Override
	protected ModelAndView handle(HttpServletRequest arg0,
			HttpServletResponse arg1, Object command, BindException arg3)
			throws Exception {
		Emp emp = (Emp)command;
		System.out.println(emp.getEmpNo()+" "+emp.getName()+" " +
				" "+emp.getHireDate());
		return new ModelAndView("success");
	}

	/**
	 * 自定义类型转换器
	 */
	@Override
	protected void initBinder(HttpServletRequest request,
			ServletRequestDataBinder binder) throws Exception {
		binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true));
	}
}
